# Makefile per il primo frammento lcs08
#
#

# uncomment for test coverage information
#   $$ gcov -f graphs
#   $$ more graphs.c.gcov
# COVFLAGS=-fprofile-arcs -ftest-coverage

CC= gcc
CFLAGS = -Wall -pedantic -g $(COVFLAGS)

objects = test-graph.o graphs.o
exe = graph

# lista di file da consegnare (.c e .h)
FILE_DA_CONSEGNARE="./graphs.c"

.PHONY: cleanall test clean consegna docu

$(exe) : $(objects)
	$(CC) $(CFLAGS) $(objects) -o $(exe)
test-graph.o: test-graph.c graphs.h
graphs.o: graphs.c graphs.h

########### NON MODIFICARE DA QUA IN POI ################
# genera la documentazione con doxygen
docu: Doxyfile
	-rm -fr html
	doxygen

# effettua il test
test: $(exe)
	@echo MALLOC_TRACE=$(MALLOC_TRACE)
	-rm -f ./.mtrace.log
	./$(exe) 
	mtrace ./$(exe) ./.mtrace.log
	@echo -e "\a\n **** Test superato! ****\n"

SUBJECT1="lcs08: consegna primo frammento"
#effettua il test e la consegna
consegna:
	make clean
	make test
	./gruppo-check.pl < gruppo.txt
	tar -cvf $(USER)-f1.tar ./gruppo.txt $(FILE_DA_CONSEGNARE)
	mpack -s $(SUBJECT1) ./$(USER)-f1.tar  susanna@di.unipi.it
	@echo -e "\a\n*** PRIMO FRAMMENTO CONSEGNATO! ***\n"

clean:
	-rm -f *.o *~ ./core 

cleanall:
	-rm -f *.o *~ ./core $(exe) *.gcno *.gcda
